<%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8" %>
<%@page import="java.io.*,java.util.*,java.sql.*,com.animal.dao.*,com.animal.bean.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>纸质档案归档</title>

<link rel="stylesheet" type="text/css" href="./bootstrap/css/bootstrap.min.css">
<link href="./bootstrap/css/styles.css" rel="stylesheet">

</head>

<body>
	<% 
	String ID = (String)session.getAttribute("ID");
	String filenumber=((String)request.getParameter("FileNumber")==null)?"":(String)request.getParameter("FileNumber");
	String filetitle=((String)request.getParameter("FileTitle")==null)?"":(String)request.getParameter("FileTitle");
	String userid=((String)request.getParameter("UserID")==null)?"":(String)request.getParameter("UserID");
	String animalid=((String)request.getParameter("AnimalID")==null)?"":(String)request.getParameter("AnimalID");
	String filetype=((String)request.getParameter("FileType")==null)?"all":(String)request.getParameter("FileType");
	%>
	<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
		<div class="container-fluid">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#sidebar-collapse">
					<span class="sr-only">Toggle navigation</span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="PaperFileManager.html"><span>实验动物</span>档案管理</a>
				<ul class="user-menu">
					<li class="dropdown pull-right">
						<a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-user"></span> User <span class="caret"></span></a>
						<ul class="dropdown-menu" role="menu">
							<li><a href="http://www.cau.edu.cn"><span class="glyphicon glyphicon-user"></span> Profile</a></li>
							<li><a href="#"><span class="glyphicon glyphicon-cog"></span> Settings</a></li>
							<li><a href="login.jsp"><span class="glyphicon glyphicon-log-out"></span> Logout</a></li>
						</ul>
					</li>
				</ul>
			</div>				
		</div>
	</nav>
		
	<div id="sidebar-collapse" class="col-sm-3 col-lg-2 sidebar">
		<form role="search">
			<div class="form-group">
				<input type="text" class="form-control" placeholder="Search">
			</div>
		</form>
		<ul class="nav menu">
			<li class="parent ">
				<a href="#">
					<span class="glyphicon glyphicon-list"></span> 管理员信息 <span data-toggle="collapse" href="#sub-item-1" class="icon pull-right"><em class="glyphicon glyphicon-s glyphicon-plus"></em></span> 
				</a>
				<ul class="children collapse" id="sub-item-1">
					<li>
						<a class="" href="PaperPersonalInfo.jsp">
							<span class="glyphicon glyphicon-share-alt"></span> 个人信息
						</a>
					</li>
					<li>
						<a class="" href="PaperChangePassword.jsp">
							<span class="glyphicon glyphicon-share-alt"></span> 修改密码
						</a>
					</li>
				</ul>
			</li>
			
			<li class="parent ">
				<a href="#">
					<span class="glyphicon glyphicon-list"></span> 纸质档案管理 <span data-toggle="collapse" href="#sub-item-2" class="icon pull-right"><em class="glyphicon glyphicon-s glyphicon-plus"></em></span> 
				</a>
				<ul class="children collapse" id="sub-item-2">
					<li>
						<a class="" href="PaperConfirmElec.jsp">
							<span class="glyphicon glyphicon-share-alt"></span> 确认电子档案
						</a>
					</li>
					<li>
						<a class="" href="PaperFileArchive.jsp">
							<span class="glyphicon glyphicon-share-alt"></span> 纸质档案归档
						</a>
					</li>
				</ul>
			</li>
			
			<li role="presentation" class="divider"></li>
			<li><a href="login.jsp"><span class="glyphicon glyphicon-user"></span>登录页面</a></li>
		</ul>
		<div class="attribution">Created by <a href="#">软工第9组</a></div>
	</div><!--/.sidebar-->
		
	
	<div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">			
		<div class="row">
			<ol class="breadcrumb">
				<li><a href="PaperFileManager.html"><span class="glyphicon glyphicon-home"></span></a></li>
				<li class="active">纸质档案管理 > 纸质档案归档</li>
			</ol>
		</div>
		
		
		
		<!-- 从这开始添加代码 -->
		
		<div class="row">
			<div class="col-lg-12">
				<h3><center><b>纸质档案管管理 > 纸质档案归档</b></center></h3>
				<br>
				<table align="center" class="table table-striped" name="search">
					<tr>
						<form>
							<td>
								<label for="FileType">档案类型:</label>
								<select class="form-control" id="FileType" name="FileType">
									<option value="all" <%if(filetype.equals("all")){%>selected<%}%>>所有档案</option>
									<option value="daily" <%if(filetype.equals("daily")){%>selected<%}%>>日常档案</option>
									<option value="exp" <%if(filetype.equals("exp")) {%>selected<%}%>>实验档案</option>	
								</select>
							</td>
							<td>
								<label for="FileNumber">档案编号:</label>
								<input type="text" name="FileNumber" class="form-control" value="<%=filenumber%>">
							</td>
							<td>
								<label for="FileTitle">档案名称:</label>
								<input type="text" name="FileTitle" class="form-control" value="<%=filetitle%>">
							</td>
							<td>
								<label for="UserID">用户编号:</label>
								<input type="text" name="UserID" class="form-control" value="<%=userid%>">
							</td>
							<td>
								<label for="AnimalID">动物编号:</label>
								<input type="text" name="AnimalID" class="form-control" value="<%=animalid%>">
							</td>
							<td>
								<input type="submit" class="btn btn-info" style="margin-top:37%" value="查询">
							</td>
						</form>
					</tr>
				</table>
				<table align="center" class="table table-striped">
					<tr>
						<th>档案编号</th>
						<th>档案名称</th>
						<th>实验日期</th>
						<th>填写日期</th>
						<th>用户编号</th>
						<th>动物编号</th>
						<th>信息备注</th>
						<th>档案状态</th>
						<th>操作</th>
					</tr>
					<tbody>
						<%						
						ArrayList explist = (ArrayList)ExpManage.selectLike(filenumber,filetitle,userid,animalid);
						ArrayList dailylist = (ArrayList)DailyManage.selectLike(filenumber,filetitle,userid,animalid);
						Iterator expit = explist.iterator();
						Iterator dailyit = dailylist.iterator();
						String expfn,dailyfn;
						if(filetype.equals("all")||filetype.equals("daily")){
							while(dailyit.hasNext()){
								DailyBean dailyfile = (DailyBean)dailyit.next();
								String state = dailyfile.getFileState();
								dailyfn = dailyfile.getFileNumber();
							%>
							<tr>
							    <td><%=dailyfile.getFileNumber() %></td>
							    <td><%=dailyfile.getFileTitle() %></td>
							    <td></td>
							    <td><%=dailyfile.getFillingDate() %></td>
							    <td><%=dailyfile.getUserID() %></td>
							    <td><%=dailyfile.getAnimalID() %></td>
							    <td><%=dailyfile.getDailyDataTip() %></td>
							      						      
							<%
							    if(state.equals("已审核")){	//未确认，蓝色，无法归档
							 %>
							    	<td><font color="blue"><b><%=dailyfile.getFileState() %></b></font></td>
							      	<td>
							      		<a class="btn btn-info" style="opacity:0.2;" OnClick="javascript:return confirm('电子档案尚未确认，无法归档');">归档</a>  
							<%	
								}
							    else if(state.equals("未审核")){  //未审核，红色，无法归档
							 %>
							      	<td><font color="red"><b><%=dailyfile.getFileState()%></b></font></td>
							      	<td>
							      		<a class="btn btn-info"  style="opacity:0.2;" OnClick="javascript:return confirm('档案尚未审核，无法归档');">归档</a>
							 <%
							    }
							    else if(state.equals("电子档案已确认")){  //已确认，绿色，可归档
							 %>
							 		<td><font color="green"><b><%=dailyfile.getFileState()%></b></font></td>
							      	<td>
							      		<a class="btn btn-info"  href="PaperArchiveServlet?do=dailycheck&id=<%=dailyfn%>" OnClick="javascript:return confirm('确认已归档纸质档案吗？');">归档</a>			
							<%
							    }
							    else if(state.equals("纸质档案已归档")){  //已归档，绿色，无需再次归档
							 %>
									<td><font color="green"><b><%=dailyfile.getFileState()%></b></font></td>
							      	<td>
							      		<a class="btn btn-info"  style="opacity:0.2;" OnClick="javascript:return confirm('纸质档案已归档，无需再次归档');">归档</a>	
							 <%
							  	}
							  %>
							 			<a class="btn btn-danger" href="PaperArchiveServlet?do=dailydel&id=<%=dailyfn %>" OnClick="javascript:return confirm('是否确认删除吗？');">删除</a>
							    	</td>
							    </tr>
		   
							<%
							}
						}
						if(filetype.equals("all")||filetype.equals("exp")){
							while(expit.hasNext()){
								ExpBean expfile = (ExpBean)expit.next();
								String state = expfile.getFileState();
								expfn = expfile.getFileNumber();
							%>
							    <tr>
							      <td><%=expfile.getFileNumber() %></td>
							      <td><%=expfile.getFileTitle() %></td>
							      <td><%=expfile.getExperimentDate() %></td>
							      <td><%=expfile.getFillingDate() %></td>
							      <td><%=expfile.getUserID() %></td>
							      <td><%=expfile.getAnimalID() %></td>
							      <td><%=expfile.getExperimentDataTip() %></td>
							      						      
							<%
							    if(state.equals("已审核")){	//未确认，蓝色，无法归档
							 %>
							    	<td><font color="blue"><b><%=expfile.getFileState() %></b></font></td>
							      	<td>
							      		<a class="btn btn-info" style="opacity:0.2;" OnClick="javascript:return confirm('电子档案尚未确认，无法归档');">归档</a>  
							<%	
								}
							    else if(state.equals("未审核")){  //未审核，红色，无法归档
							 %>
							      	<td><font color="red"><b><%=expfile.getFileState()%></b></font></td>
							      	<td>
							      		<a class="btn btn-info"  style="opacity:0.2;" OnClick="javascript:return confirm('档案尚未审核，无法归档');">归档</a>
							 <%
							    }
							    else if(state.equals("电子档案已确认")){  //已确认，绿色，可归档
							 %>
							 		<td><font color="green"><b><%=expfile.getFileState()%></b></font></td>
							      	<td>
							      		<a class="btn btn-info"  href="PaperArchiveServlet?do=expcheck&id=<%=expfn%>" OnClick="javascript:return confirm('确认已归档纸质档案吗？');">归档</a>			
							<%
							    }
							    else if(state.equals("纸质档案已归档")){  //已归档，绿色，无需再次归档
							 %>
									<td><font color="green"><b><%=expfile.getFileState()%></b></font></td>
							      	<td>
							      		<a class="btn btn-info"  style="opacity:0.2;" OnClick="javascript:return confirm('纸质档案已归档，无需再次归档');">归档</a>	
							 <%
							  	}
							  %>
							 			<a class="btn btn-danger" href="PaperArchiveServlet?do=expdel&id=<%=expfn %>" OnClick="javascript:return confirm('是否确认删除吗？');">删除</a>
							    	</td>
							    </tr>   
							<%
							}
						}
							%>	    
					</tbody>
				</table>											
			</div>			
		</div>
	</div>
	
	<script src="./bootstrap/js/jquery-3.1.0.min.js"></script>
	<script src="./bootstrap/js/bootstrap.min.js"></script>
	
	<script>
		!function ($) {     
 		    $(document).on("click","ul.nav li.parent > a > span.icon", function(){          
		        $(this).find('em:first').toggleClass("glyphicon-minus");      
		    }); 
		    $(".sidebar span.icon").find('em:first').addClass("glyphicon-plus");
		}(window.jQuery);
		/**
		$(window).on('resize', function () {
			  if ($(window).width() > 768) $('#sidebar-collapse').collapse('show')
			})
			$(window).on('resize', function () {
			  if ($(window).width() <= 767) $('#sidebar-collapse').collapse('hide')
			})
			*/
	</script>

</body>

</html>
